#define FPS 30

#include "SDL.h"
#include "monitokun.h"
#include "background.h"

int startFPS;
void fps();

int main( int argc, char* args[] )
{
	//boolean for loop of game
	bool quit = false;
	
	startFPS = SDL_GetTicks();
	
	monitokun *mono1;
	monitokun *mono2;

	background *bckgrnd;

	SDL_Rect offset;
	SDL_Surface *screen = NULL;

	//Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );
    
	screen = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE);
	//screen = SDL_SetVideoMode(640,480,32,SDL_FULLSCREEN);

	offset.x = 50;
	offset.y = 50;
	mono1->getInstance()->characterToLoad("resources/mono.png");
	bckgrnd->getInstance()->backgroundToLoad();

	//mono2->getInstance()->characterToLoad("resources/mono.png");
	//mono2->getInstance()->draw(screen,offset);
	//mono2->getInstance()->update(screen);
	//mono2->getInstance()->setFree();

	//monitokun::getInstance()->characterToLoad("resources/mono.png");
	//monitokun::getInstance()->draw(screen);
	//monitokun::getInstance()->update(screen);
	//monitokun::getInstance()->setFree();

	//While the user hasn't quit

    while( quit == false )
    {
		fps();
		//bckgrnd->getInstance()->update(screen);
		bckgrnd->getInstance()->draw(screen);

		//mono1->getInstance()->update(screen);
		mono1->getInstance()->updateKeys();
		mono1->getInstance()->draw(screen);
		SDL_Flip(screen);

	}

	mono1->getInstance()->setFree();
	bckgrnd->getInstance()->setFree();
    //Quit SDL
    SDL_Quit();
    
    return 0;    
}

void fps()
{
	if( 1000/FPS > SDL_GetTicks()-startFPS )
	{
		SDL_Delay( 1000/FPS - ( SDL_GetTicks()-startFPS ));
	}
}